package com.jiyun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiyun.mapper.CommentMapper;
import com.jiyun.pojo.Comment;
import com.jiyun.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author: 刘清芳
 * @description:
 * @date: 2023/12/28 17:24
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment>implements CommentService {
    @Autowired
    CommentService commentService;
    @Override
    public Page<Comment> findAllComment(Comment comment, Integer pageNum, Integer pageSize) {
        // 创建一个包含分页信息的Page对象，设置每页显示的记录数
        Page<Comment> commentPage = new Page<>(pageNum, pageSize);
        // 创建一个LambdaQueryWrapper对象，用于构建查询条件
        LambdaQueryWrapper<Comment> wrapper = new LambdaQueryWrapper<>();
        // 调用commentService的page方法，根据指定的分页信息和查询条件，获取评论的分页数据
        commentService.page(commentPage, wrapper);
//       return 返回结果
        return commentPage;

    }

    @Override
    public void updatehuif(Comment comment) {
        comment.setContentTime(new Date());
        commentService.updateById(comment);
    }
}
